<div id="container">
<?php if (!$this->allow('list')) : ?>
	<div class="grid_12 t_a_bottom">
		<?php echo $this->translator->translator('Member_Access_deny_desc'); ?>
	</div>
<?php 
else : 
echo $this->headScript()->setFile($this->baseUrl().'/js/jquery/table-sorter/jquery.dataTables.js');
$group_Info = new Menu_Model_DbTable_MenuGroup();
$permission_arr = array('add_enable' => $this->allow('add','backend','Menu'), 'edit_enable' => $this->allow('edit','backend','Menu'), 'publish_enable' => $this->allow('publish','backend','Menu'), 'delete_enable' => $this->allow('delete','backend','Menu'), 'primary_enable' => $this->allow('primary','backend','Menu'));
$mem_db = new Members_Model_DbTable_MemberList();
$auth = Zend_Auth::getInstance ();
?>
<script type="text/javascript">
$(document).ready(function() {
	
	$('a.search_btn').click(function(){
		$('#searchForm').submit();
	});	
	
	floatingbar('#floatingbar',"#button_top_bar",null);	
	/****************************Sorting Table Start*********************/
	var oTable = $("#sortTable").dataTable({
				"bPaginate": false,
				"bLengthChange": true,
				"bSearchable": true,
				"bFilter": true,
				"bSort": true,
				"bInfo": false,
				"bAutoWidth": true,
				"bProcessing": false,
				"bSortClasses": true,
				"bStateSave": false,
				"bServerSide": false,
				"aaSorting": [[ 2, "asc" ]],				
				"aoColumnDefs": [ 
						{ "bSortable": false, "bSortClasses": false,  "aTargets": [ 0 ] }
					],
				"oLanguage" : { "sSearch": "<?php echo $this->translator->translator('jquery_filter'); ?>" }
			}); 	
	
	$('td', oTable.fnGetNodes()).hover( function() {		
		$(this).parents("tr:first").children('td').addClass( 'highlighted' );
	}, function() {
		$('td.highlighted').removeClass('highlighted');
	} );
	
	/* Get the rows which are currently selected */
	function fnGetSelected( oTableLocal )
	{
		var aReturn = new Array();
		var aTrs = oTableLocal.fnGetNodes();
		
		for ( var i=0 ; i<aTrs.length ; i++ )
		{
			if ( $(aTrs[i]).hasClass('row_selected') )
			{
				aReturn.push( aTrs[i] );
			}
		}
		return aReturn;
	}
	
	lastClassAdd(oTable);	
	
	/****************************Sorting Table End*********************/
	
		function openMsgDialog(msg)
		{
			$('#dialog_container').html(msg).dialog({
				autoOpen: true,
				modal: false,
				show: 'fade',
				resizable: 'false',				
				buttons: { "<?php echo html_entity_decode($this->translator->translator('common_ok'), ENT_QUOTES, 'UTF-8'); ?>": function() { $(this).dialog('option', 'hide', 'explode').dialog("close"); } },
				open: function(event, ui)
					 {
						setTimeout(function() 
						{									
							if($('#' + event.target.id).dialog('isOpen'))
							{
								$('#' + event.target.id).dialog('option', 'hide', 'explode').dialog('close');										
							}
						}, 10000);
					  }
			});
		}
		
		function deleteThis(self)
		{
			var arr = $(self).attr('rel').split('_');
			$.ajax({
				 url: "<?php echo $this->url( array('module'=> 'Menu', 'controller' => 'backend', 'action'     => 'delete' ), 'adminrout',    true) ?>",
				 type: 'POST',
				 data: { menu_id: arr[0], menu_name: arr[1] },
				 beforeSend: function(){
						$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/loader/ajax_loader.gif" height="19" border="0" />');
					 },
				 success: function(response) 
				 {
					//alert(response);
					var json_arr = eval("("+response+")");
					if(json_arr.status == 'ok')
					{
						$(self).parents("li:first").parents("ul:first").parents("td:first").parents("tr:first").addClass('row_selected');
						var oTables = $('#sortTable').dataTable();
						var anSelected = fnGetSelected( oTables );
						oTables.fnDeleteRow( anSelected[0] );
						lastClassAdd(oTables);
					}
					else
					{
						openMsgDialog(json_arr.msg);
						$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/delete.png" title="<?php echo addslashes($this->translator->translator("common_delete_title")); ?>" alt="<?php echo addslashes($this->translator->translator("common_delete_title")); ?>" border="0" />');
					}
				 }
			});
		}
		
		function checkNonDeletedId(id,id_arr)
		{
			var tmp = false;
			for(var i = 0;i < id_arr.length;i++)
			{
				if(id_arr[i] == id)
				{
					tmp = true;
					break;
				}
			}
			return tmp;
		}
		
		function deleteAll(self)
		{
			var menu_id_str = '';
			for(var i=0;i < $('input.check_btn:checked').length;i++)
			{
				if(i == 0)
				{
					 menu_id_str += $('input.check_btn:checked:eq('+i+')').val();
				}
				else
				{
					menu_id_str += ','+$('input.check_btn:checked:eq('+i+')').val();
				}
			}
			
			$.ajax({
					url: "<?php echo $this->url( array('module'=> 'Menu', 'controller' => 'backend', 'action'     => 'deleteall' ), 'adminrout',    true) ?>",
				 	type: 'POST',
				 	data: { menu_id_st: menu_id_str},
					beforeSend: function(){
						$(self).html('<span class="icon loader"></span>');
					 },
					success: function(response) 
				 	{
						//alert(response);
						var json_arr = eval("("+response+")");
						if(json_arr.status == 'ok')
						{
							for(var i= ($('input.check_btn:checked').length-1);i >= 0;i--)
							{								
								if(!checkNonDeletedId($('input.check_btn:checked:eq('+i+')').val(),json_arr.non_del_arr))
								{
									$('input.check_btn:checked:eq('+i+')').parents("td:first").parents("tr:first").addClass('row_selected');	
								}							
							}
							var oTabled = $('#sortTable').dataTable();
							var anSelected = fnGetSelected( oTabled );
							for(var k = 0; k < anSelected.length; k++)
							{
								oTabled.fnDeleteRow( anSelected[k] );
							}
							lastClassAdd(oTabled);
						}
						else
						{							
							openMsgDialog(json_arr.msg);
						}	
						$(self).html('<span class="icon delete"><?php echo html_entity_decode($this->translator->translator("common_delete_selected"), ENT_QUOTES, "UTF-8"); ?></span>');
					}
			});	
		}
	
	$('a.delete_btn').click(function() {
		var self = this;
		$("#dialog-confirm").html("<?php echo addslashes($this->translator->translator('menu_list_delete_confirm')); ?>").dialog({
			resizable: false,
			width:400,
			height:170,
			modal: true,
			show: 'fade',
			hide: 'explode',
			buttons: {
					'<?php echo html_entity_decode($this->translator->translator("common_delete"), ENT_QUOTES, "UTF-8"); ?>': function() {
					deleteThis(self);
					$(this).dialog('close');
				},
			'<?php echo html_entity_decode($this->translator->translator("common_cancel"), ENT_QUOTES, "UTF-8"); ?>': function() {
					$(this).dialog('close');
				}
			}
		});
		
	});
	
	$('a.publish_btn').click(function() {
		<?php if ($permission_arr['publish_enable']) { ?>
			var self = this;			
			var arr = $(self).attr('rel').split('_');
			$.ajax({
				 url: "<?php echo $this->url( array('module'=> 'Menu', 'controller' => 'backend', 'action'     => 'publish' ), 'adminrout',    true) ?>",
				 type: 'POST',
				 data: { menu_id: arr[0], menu_name: arr[1], paction: arr[2]},
				 beforeSend: function(){
					$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/loader/ajax_loader.gif" height="16" border="0" />');
				 },
				 success: function(response) 
				 {
					//alert(response);
					var json_arr = eval("("+response+")");
					if(json_arr.status == 'ok')
					{
						if(json_arr.menu_status == '1')
						{
							$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/published.gif" border="0" title="<?php echo $this->translator->translator("common_unpublish_title"); ?>" />').attr('rel',arr[0]+"_"+arr[1]+"_unpublish");
						}
						else
						{
							$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/unpublished.gif" border="0" title="<?php echo $this->translator->translator("common_publish_title"); ?>" />').attr('rel',arr[0]+"_"+arr[1]+"_publish");
						}
					}
					else
					{
						openMsgDialog(json_arr.msg);
					}
				 }				
			});
		<?php }else{ ?>
			var msg = "<?php echo $this->translator->translator('common_publish_perm'); ?>";
				openMsgDialog(msg);
		<?php } ?>
	});
	
	
	$('a.dafault_btn').click(function() {
		var self = this;				
		var arr = $(self).attr('rel').split('_');
		var hrf = $(self).attr('href');
		if(hrf != null)
		{			
			$.ajax({
				 url: "<?php echo $this->url( array('module'=> 'Menu', 'controller' => 'backend', 'action'     => 'primary' ), 'adminrout',    true) ?>",
				 type: 'POST',
				 data: { menu_id: arr[0], menu_name: arr[1]},
				 beforeSend: function(){
					$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/loader/ajax_loader.gif" height="19" border="0" />');
				 },
				 success: function(response) 
				 {
					var json_arr = eval("("+response+")");
					if(json_arr.status == 'ok')
					{						
						$('a.dafault_btn').html('<img src="application/modules/Administrator/layouts/scripts/images/tools/undefault.gif" border="0" title="<?php echo $this->translator->translator("menu_default_title"); ?>" />');
						$('a.dafault_btn').attr('href','javascript: void(0)');						
						
						$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/default.gif" border="0" title="<?php echo $this->translator->translator("menu_defaulted_title"); ?>" />');
						$(self).removeAttr("href");					
					}
					else
					{
						openMsgDialog(json_arr.msg);
						$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/undefault.gif" border="0" title="<?php echo $this->translator->translator("menu_default_title"); ?>" />');
					}
				 }		
			});
		}
	});
	
	$('a.up_btn').click(function() {
		var self = this;				
		var arr = $(self).attr('rel').split('_');		
		var prev_order = $(self).parents("td:first").children("input:nth-child(1)").val();		
		$.ajax({
				 url: "<?php echo $this->url( array('module'=> 'Menu', 'controller' => 'backend', 'action'     => 'up' ), 'adminrout',    true) ?>",
				 type: 'POST',
				 data: { menu_id: arr[0], menu_order: prev_order},
				 beforeSend: function(){
					$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/up-animation.gif" border="0" />');
				 },
				 success: function(response) 
				 {
				 	// alert(response);
					var json_arr = eval("("+response+")");
					if(json_arr.status == 'ok')
					{
						$(self).parents("td:first").children("input:nth-child(1)").val((prev_order-1));
						if(json_arr.id_arr != '' && json_arr.id_arr != null)
						{
							for(var i = 0; i < json_arr.id_arr.length; i++)
							{
								for(var j=0;j < $('a.up_btn').length ;j++)
								{
									var arrUp = $('a.up_btn:eq('+j+')').attr('rel').split('_');									
									if(arrUp[0] == json_arr.id_arr[i])	
									{										
										$('a.up_btn:eq('+j+')').parents("td:first").children("input:nth-child(1)").val(prev_order);
									}					
								}
							}							
						}						
					}
					else
					{
						openMsgDialog(json_arr.msg);
					}
					$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/up-arrow.gif" border="0" />');
				 }
			});
	});	
	
	$('a.down_btn').click(function() {
		var self = this;				
		var arr = $(self).attr('rel').split('_');		
		var prev_order = $(self).parents("td:first").children("input:nth-child(1)").val();		
		
		$.ajax({
				 url: "<?php echo $this->url( array('module'=> 'Menu', 'controller' => 'backend', 'action'     => 'down' ), 'adminrout',    true) ?>",
				 type: 'POST',
				 data: { menu_id: arr[0], menu_order: prev_order},
				 beforeSend: function(){
					$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/down-animation.gif" border="0" />');
				 },
				 success: function(response) 
				 {
				 	// alert(response);
					var json_arr = eval("("+response+")");
					if(json_arr.status == 'ok')
					{
						var new_order = parseInt(prev_order) + 1;
						$(self).parents("td:first").children("input:nth-child(1)").val(new_order);
						if(json_arr.id_arr != '' && json_arr.id_arr != null)
						{
							for(var i = 0; i < json_arr.id_arr.length; i++)
							{
								for(var j=0;j < $('a.up_btn').length ;j++)
								{
									var arrUp = $('a.up_btn:eq('+j+')').attr('rel').split('_');									
									if(arrUp[0] == json_arr.id_arr[i])	
									{										
										$('a.up_btn:eq('+j+')').parents("td:first").children("input:nth-child(1)").val(prev_order);
									}					
								}
							}							
						}						
					}
					else
					{
						openMsgDialog(json_arr.msg);
					}
					$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/down-arrow.gif"  border="0" />');
				 }
			});
	});
	
	
	$('a.all_order_btn').click(function() {
		var self = this;
		var menu_order_str = '';
		var menu_id_str = '';
		for(var i=0;i<$('input.menu_order_text').length;i++)
		{
			if(i == 0)
			{
				menu_order_str += $('input.menu_order_text:eq('+i+')').val();
				menu_id_str += $('input.menu_order_text:eq('+i+')').parents("td:first").children("a:first").attr('rel');
			}
			else
			{
				menu_order_str += ','+$('input.menu_order_text:eq('+i+')').val();
				menu_id_str += ','+$('input.menu_order_text:eq('+i+')').parents("td:first").children("a:first").attr('rel');
			}
		}
		
		$.ajax({
				 url: "<?php echo $this->url( array('module'=> 'Menu', 'controller' => 'backend', 'action'     => 'orderall' ), 'adminrout',    true) ?>",
				 type: 'POST',
				 data: { menu_id_arr: menu_id_str, menu_order_arr: menu_order_str},
				 beforeSend: function(){
					oTable.fnSettings().aoColumns[4].bSortable = false;
					$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/loader/ajax_loader.gif" height="16" border="0" />');
				 },
				 success: function(response) 
				 {
				 	//alert(response);
					var json_arr = eval("("+response+")");
					openMsgDialog(json_arr.msg);
					$(self).html('<img src="application/modules/Administrator/layouts/scripts/images/tools/save.png" border="0" />');
				 	oTable.fnSettings().aoColumns[4].bSortable = true;
				 }
		});
	});
	
	$('a.publish_all').click(function() {
		<?php if ($permission_arr['publish_enable']) { ?>
			var self = this;
			var bigrel = $(self).attr('rel');
			if($('input.check_btn:checked').length > 0)
			{
				var menu_id_str = '';
				for(var i=0;i < $('input.check_btn:checked').length;i++)
				{
					if(i == 0)
					{
						 menu_id_str += $('input.check_btn:checked:eq('+i+')').val();
					}
					else
					{
						menu_id_str += ','+$('input.check_btn:checked:eq('+i+')').val();
					}
				}
				
				$.ajax({
						url: "<?php echo $this->url( array('module'=> 'Menu', 'controller' => 'backend', 'action'     => 'publishall' ), 'adminrout',    true) ?>",
						type: 'POST',
						data: { menu_id_st: menu_id_str, paction: bigrel},
						beforeSend: function(){
							$(self).html('<span class="icon loader"></span>');
						 },
						success: function(response) 
						{
							//alert(response);
							var json_arr = eval("("+response+")");
							if(json_arr.status == 'ok')
							{
								if(bigrel=='publish')
								{
									for(var i=0;i < $('input.check_btn:checked').length;i++)
									{	
										var rel = $('input.check_btn:checked:eq('+i+')').parents("td:first").parents("tr:first").children("td:nth-child(6)").children("a:nth-child(1)").attr('rel');
										var rel_arr = rel.split('_');
										var new_rel = rel_arr[0]+'_'+rel_arr[1]+'_unpublish';
										$('input.check_btn:checked:eq('+i+')').parents("td:first").parents("tr:first").children("td:nth-child(6)").children("a:nth-child(1)").attr('rel',new_rel);
										$('input.check_btn:checked:eq('+i+')').parents("td:first").parents("tr:first").children("td:nth-child(6)").children("a:nth-child(1)").html('<img src="application/modules/Administrator/layouts/scripts/images/tools/published.gif" border="0" title="<?php echo $this->translator->translator("common_unpublish_title"); ?>" />');								
									}
								}
								else
								{
									for(var i=0;i < $('input.check_btn:checked').length;i++)
									{	
										var rel = $('input.check_btn:checked:eq('+i+')').parents("td:first").parents("tr:first").children("td:nth-child(6)").children("a:nth-child(1)").attr('rel');
										var rel_arr = rel.split('_');
										var new_rel = rel_arr[0]+'_'+rel_arr[1]+'_publish';
										$('input.check_btn:checked:eq('+i+')').parents("td:first").parents("tr:first").children("td:nth-child(6)").children("a:nth-child(1)").attr('rel',new_rel);
										$('input.check_btn:checked:eq('+i+')').parents("td:first").parents("tr:first").children("td:nth-child(6)").children("a:nth-child(1)").html('<img src="application/modules/Administrator/layouts/scripts/images/tools/unpublished.gif" border="0" title="<?php echo $this->translator->translator("common_publish_title"); ?>" />');								
									}	
								}
							}
							else
							{
								openMsgDialog(json_arr.msg);
							}	
							if(bigrel=='publish')
							{	
								$(self).html('<span class="icon publish"><?php echo $this->translator->translator("common_publish_selected"); ?></span>');
							}
							else
							{
								$(self).html('<span class="icon unpublish"><?php echo $this->translator->translator("common_unpublish_selected"); ?></span>');
							}
						}
				});			
			}
			else
			{
				var msg = "<?php echo $this->translator->translator('menu_selected_err'); ?>";
				openMsgDialog(msg);
			}
		<?php }else{ ?>
			var msg = "<?php echo $this->translator->translator('common_publish_perm'); ?>";
				openMsgDialog(msg);
		<?php } ?>
	});
		
	$('a.delete_all').click(function() {
		var self = this;
		if($('input.check_btn:checked').length > 0)
		{
			$("#dialog-confirm").html("<?php echo addslashes($this->translator->translator('menu_list_delete_confirm')); ?>").dialog({
					resizable: false,
					width:400,
					height:170,
					modal: true,
					show: 'fade',
					hide: 'explode',
					buttons: {
							'<?php echo html_entity_decode($this->translator->translator("common_delete_selected"), ENT_QUOTES, "UTF-8"); ?>': function() {
							deleteAll(self);
							$(this).dialog('close');
						},
					'<?php echo html_entity_decode($this->translator->translator("common_cancel"), ENT_QUOTES, "UTF-8"); ?>': function() {
							$(this).dialog('close');
						}
					}
				});		
		}
		else
		{
			var msg = "<?php echo $this->translator->translator('menu_selected_err'); ?>";
			openMsgDialog(msg);
		}
	});
	
	$('input.checkAll_btn').click(function() {
		var self = this;
		if($(self).is(':checked'))
		{		
			$('input.check_btn').attr('checked', true);
		}
		else
		{
			$('input.check_btn').attr('checked', false);
		}
	});
	
	
	
});
</script>

<div class="title-container">
	<div class="menu"><h1><?php if($this->draft_menu != null){  echo $this->translator->translator('menu_list_draft_page_name'); }else{ echo $this->translator->translator('menu_list_page_name'); } ?></h1></div>
    
    <div class="button-container">
        <?php if ($permission_arr['add_enable']) : ?>
        <span class="button  ui-widget-content-1"><a href="<?php echo $this->url(array('module'=> 'Menu','controller'=>'Backend', 'action'=>'add'),'adminrout',true);?>"><span class="icon add"><?php echo $this->translator->translator('common_add'); ?></span></a></span>
        <?php endif; ?>
        <?php if ($permission_arr['publish_enable']) : ?>
        <span class="button  ui-widget-content-1"><a href="javascript: void(0);" rel="publish" class="publish_all"><span class="icon publish"><?php echo $this->translator->translator('common_publish_selected'); ?></span></a></span>
        <?php endif; ?>
        <?php if ($permission_arr['publish_enable']) : ?>
        <span class="button  ui-widget-content-1"><a href="javascript: void(0);" rel="unpublish" class="publish_all"><span class="icon unpublish"><?php echo $this->translator->translator('common_unpublish_selected'); ?></span></a></span>
        <?php endif; ?>
        <?php if ($permission_arr['delete_enable']) : ?>
        <span class="button  ui-widget-content-1"><a href="javascript: void(0);" class="delete_all"><span class="icon delete"><?php echo html_entity_decode($this->translator->translator("common_delete_selected"), ENT_QUOTES, "UTF-8"); ?></span></a></span>
        <?php endif; ?>
    </div>
</div>
<div id="button_top_bar"></div>
<div class="content-container">
	<p>
		<?php echo $this->translator->translator('menu_list_tips_desc'); ?>
    </p>
    <br />
	<div id="sidebar-inner">
    	<?php echo $this->partial('backend/nav_menu.phtml');  ?>
    </div>
    
    
    <div id="content-inner">    	
    	<div class="toggle-container">
         	<form name="searchForm" id="searchForm" action="<?php echo $this->url( array('module' => 'Menu','controller' => 'backend', 'action'     => 'list' ), 'adminrout',    true) ?>" method="get">
                <div class="toggle-search">
                	<!-- Row 1 Start -->
                    <div class="toggle-row">
                        <div class="toggle-label">
                            <span class="label"><?php echo $this->translator->translator('menu_list_page_search_name'); ?></span>
                        </div>
                        
                        <div class="toggle-field">
                            <input type="text" class="ui-widget-content ui-corner-all" name="menu_name" id="menu_name" value="<?php echo $this->postData['menu_name']; ?>" size="50" maxlength="100" />
                        </div>
                         
                 	</div>
                    <!-- Row 1 End -->
                    
                    <!-- Row 2 Start -->
                    <div class="toggle-row">
                        <div class="toggle-label">
                            <span class="label"><?php echo $this->translator->translator('menu_list_page_menu_group'); ?></span>
                        </div>
                       
                        <div class="toggle-field">
                            <?php 
								$menu_group_db = new Menu_Model_DbTable_MenuGroup();
								$menu_group_data = $menu_group_db->getGroupInfo(); 
							?>
                            <select name="group_id" id="group_id" class="ui-widget-content ui-corner-all">
                            	<option value="any"><?php echo $this->translator->translator('common_any_language'); ?></option>
                                   <?php $selected = ($this->postData['group_id'] == '0') ? 'selected="selected"' : ''; ?>                               
								   <?php
                                   if($menu_group_data)
                                   { 
                                        foreach($menu_group_data as $key=>$value)
                                        {
                                            $selected = ($this->postData['group_id'] == $key) ? 'selected="selected"' : '';
                                    ?>
                                        <option value="<?php echo $key; ?>" <?php echo $selected; ?>><?php echo $this->escape($value); ?></option>
                                   <?php
                                        }
                                   }
                                   ?>
                            </select>                  
                        </div>
                        
                        <?php
						if($auth->hasIdentity() && $auth->getIdentity()->access_other_user_article == '1')
						{
						?>
                        <div class="toggle-label">
                            <span class="label"><?php echo $this->translator->translator('menu_list_page_entry_by'); ?></span>
                        </div>
                        
                        <div class="toggle-field">
                        	<?php $mem_data = $mem_db->getAllMembers(); ?>
                            <select name="entry_by" id="entry_by" class="ui-widget-content ui-corner-all">
                            	<option value="any"><?php echo $this->translator->translator('common_any_language'); ?></option>
                                <?php 
								if($mem_data)
								{
									foreach($mem_data as $key=>$value)
                                    {
										$selected = ($this->postData['entry_by'] == $key) ? 'selected="selected"' : '';
                                ?>
                                    <option value="<?php echo $key; ?>" <?php echo $selected; ?>><?php echo $this->escape($value); ?></option>
                                <?php
                                    }
								}
                                ?>
                            </select>
                        </div>
                        <?php
						}
						?>
                        
                 	</div>
                    <!-- Row 2 End -->  
                    
                                     
                   
				</div>
                <hr />
                <div class="clr form-button-container">
                    <span class="button ui-widget-content-1"><a href="javascript: void(0);" class="search_btn"><span class="icon search"><?php echo $this->translator->translator('menu_list_page_search_button'); ?></span></a></span>
                </div>
        	</form>
     	</div>
        
    	<div class="pagination">
        	<?php echo $this->paginationControl($this->menu_datas, 'Sliding', 'backend/top_pagination.phtml'); ?>
        </div>
        
        <div class="chart">
        	<div class="data-table">
            	<table id="sortTable" width="100%" cellpadding="0" cellspacing="0">
                	<thead>
                   		<tr>
                     		<th width="2%"><input type="checkbox" name="checkAll" id="checkAll" class="checkAll_btn" /></th>
                   		  <th width="5%"><?php echo $this->translator->translator('menu_list_page_id'); ?></th>
                      		<th width="14%"><?php echo $this->translator->translator('menu_list_page_grp'); ?></th>
                       		<th width="41%"><?php echo $this->translator->translator('menu_list_page_menu_name'); ?> </th>
                        	<th width="9%">
                            	<?php echo $this->translator->translator('common_order'); ?>
                               	<a href="javascript: void(0);" class="all_order_btn"><img src="application/modules/Administrator/layouts/scripts/images/tools/save.png" border="0" /></a>
                        	</th>
                      		<th width="8%"><?php echo $this->translator->translator('common_status'); ?></th>												 
                      		<th width="18%"><?php echo $this->translator->translator('common_action'); ?></th>
                    	</tr>
					</thead>
                    <tbody>
                    <?php 
                    $j = 1;
                    foreach ($this->menu_datas as $entry): 
                        if($j % 2 == 0)
                        {
                            $onmouseout = "this.bgColor='#FFFFFF';";
                            $background = '#FFFFFF';
                        }
                        else
                        {
                            $onmouseout = "this.bgColor='#F7F7F7';";
                            $background = '#F7F7F7';
                        }
                        $link = $group_Info->getMenuLink($this->escape($entry->menu_id),$this->escape($entry->menu_title),$this);
                    ?>
                   		<tr  bgcolor="<?php echo $background; ?>" onmouseover="this.bgColor='#FCF5DD';" onmouseout="<?php echo $onmouseout; ?>">
                     		<td class="center checkbox"><input type="checkbox" name="checkbtn" id="checkbtn" value="<?php echo $this->escape($entry->menu_id); ?>" class="check_btn" /></td>
                      		<td class="center"><?php echo $this->escape($entry->menu_id); ?></td>
                      		<td>
								<?php 												  					 
                               		$group_name = $group_Info->getGroupName($this->escape($entry->group_id));
                                  	echo $this->escape($group_name['group_name']);
                   				?>
                    		</td>
                     
                      		<td><a href="<?php echo $this->url( array('module'=> 'Menu', 'controller' => 'backend', 'action'     => 'edit', 'menu_id' => $this->escape($entry->menu_id) ), 'adminrout',    true); ?>">
							<?php 
								if($this->postData && !empty($this->postData['menu_name']))
								{									
									echo Menu_View_Helper_SubMenu::highlightMenu($this->postData['menu_name'], $this->escape($entry->menu_name));
								}
								else
								{
									echo $this->escape($entry->menu_name); 
								}
							?></a></td>
                      		<td class="center">
                           		<input type="text" size="1" name="menu_order" id="menu_order" class="menu_order_text" value="<?php echo $this->escape($entry->menu_order); ?>" />
                               	<a href="javascript: void(0);" rel="<?php echo $this->escape($entry->menu_id); ?>" class="up_btn"><img src="application/modules/Administrator/layouts/scripts/images/tools/up-arrow.gif" border="0" /></a>&nbsp;<a href="javascript: void(0);" rel="<?php echo $this->escape($entry->menu_id); ?>" class="down_btn"><img src="application/modules/Administrator/layouts/scripts/images/tools/down-arrow.gif" border="0" /></a>
                      		</td>
                      		<td class="center">
								<a href="javascript:void(0);" class="publish_btn" rel="<?php echo $this->escape($entry->menu_id); ?>_<?php echo $this->escape($entry->menu_name); ?>_<?php if($this->escape($entry->menu_status) == '1'){ ?>unpublish<?php }else{ ?>publish<?php } ?>"><?php if($this->escape($entry->menu_status) == '1'){ ?><img src="application/modules/Administrator/layouts/scripts/images/tools/published.gif" border="0" title="<?php echo $this->translator->translator('common_unpublish_title'); ?>" /><?php }else{ ?><img src="application/modules/Administrator/layouts/scripts/images/tools/unpublished.gif" border="0" title="<?php echo $this->translator->translator('common_publish_title'); ?>" /><?php } ?></a>
                      		</td>
                      
                      		<td class="tools-list">
                           		<ul>
                                <?php if ($permission_arr['edit_enable']) : ?>
                                <li><a href="<?php echo $this->url( array('module'=> 'Menu', 'controller' => 'backend', 'action'     => 'edit', 'menu_id' => $this->escape($entry->menu_id) ), 'adminrout',    true) ?>"><img src="application/modules/Administrator/layouts/scripts/images/tools/edit.png" title="<?php echo $this->translator->translator('common_edit_title'); ?>" alt="<?php echo $this->translator->translator('common_edit_title'); ?>" border="0" /></a></li>
                                <?php endif; ?>
                                
                                <?php if ($permission_arr['delete_enable']) : ?>
                                <li><a href="javascript:void(0);" class="delete_btn"  rel="<?php echo $this->escape($entry->menu_id); ?>_<?php echo $this->escape($entry->menu_name); ?>"><img src="application/modules/Administrator/layouts/scripts/images/tools/delete.png" title="<?php echo $this->translator->translator('common_delete_title'); ?>" alt="<?php echo addslashes($this->translator->translator('common_delete_title')); ?>" border="0" /></a></li>
                                <?php endif; ?>
                                
                                <?php if ($permission_arr['primary_enable']) : ?>
                                    <?php if($this->escape($entry->menu_default) == '1'){ ?>
                                        <li><a rel="<?php echo $this->escape($entry->menu_id); ?>_<?php echo $this->escape($entry->menu_name); ?>" class="dafault_btn"><img src="application/modules/Administrator/layouts/scripts/images/tools/default.gif" border="0" title="<?php echo $this->translator->translator('menu_defaulted_title'); ?>" alt="<?php echo $this->translator->translator('menu_defaulted_title'); ?>" /></a></li>
                                    <?php }else{ ?>
                                        <li><a href="javascript:void(0);" rel="<?php echo $this->escape($entry->menu_id); ?>_<?php echo $this->escape($entry->menu_name); ?>" class="dafault_btn" ><img src="application/modules/Administrator/layouts/scripts/images/tools/undefault.gif" border="0" title="<?php echo $this->translator->translator('menu_default_title'); ?>" alt="<?php echo $this->translator->translator('menu_default_title'); ?>" /></a></li>
                                    <?php } ?>
                                <?php endif; ?>
                                
                                <li><a href="<?php echo $link; ?>" target="_blank" ><img src="application/modules/Administrator/layouts/scripts/images/tools/preview.gif" border="0" title="<?php echo $this->translator->translator('common_preview_title'); ?>" alt="<?php echo $this->translator->translator('common_preview_title'); ?>" /></a></li>
                                </ul>
                            </td>
                    </tr>
                    <?php
                        if(Menu_View_Helper_SubMenu::checkChild($this->escape($entry->menu_id),$this->escape($entry->group_id),$this->draft_menu))
                        { 
                            echo Menu_View_Helper_SubMenu::getSubMenu($this->escape($entry->menu_id),$this,$group_Info,'&nbsp;&nbsp;|____',$j,$this->draft_menu, $permission_arr, $this->postData);
                        }
                        $j++;
                        endforeach;	
                  	?>
                   	</tbody>
				</table>
            </div>
		</div>
        
        <div class="pagination">
        	<?php echo $this->paginationControl($this->menu_datas, 'Sliding', 'backend/pagination.phtml'); ?>
        </div>
  	</div>
</div>

<div  id="floatingbar">
	<h1><?php if($this->draft_menu != null){  echo $this->translator->translator('menu_list_draft_page_name'); }else{ echo $this->translator->translator('menu_list_page_name'); } ?></h1>
    
    <div class="button-container">
        <?php if ($permission_arr['add_enable']) : ?>
        <span class="button  ui-widget-content-1"><a href="<?php echo $this->url(array('module'=> 'Menu','controller'=>'Backend', 'action'=>'add'),'adminrout',true);?>"><span class="icon add"><?php echo $this->translator->translator('common_add'); ?></span></a></span>
        <?php endif; ?>
        <?php if ($permission_arr['publish_enable']) : ?>
        <span class="button  ui-widget-content-1"><a href="javascript: void(0);" rel="publish" class="publish_all"><span class="icon publish"><?php echo $this->translator->translator('common_publish_selected'); ?></span></a></span>
        <?php endif; ?>
        <?php if ($permission_arr['publish_enable']) : ?>
        <span class="button  ui-widget-content-1"><a href="javascript: void(0);" rel="unpublish" class="publish_all"><span class="icon unpublish"><?php echo $this->translator->translator('common_unpublish_selected'); ?></span></a></span>
        <?php endif; ?>
        <?php if ($permission_arr['delete_enable']) : ?>
        <span class="button  ui-widget-content-1"><a href="javascript: void(0);" class="delete_all"><span class="icon delete"><?php echo html_entity_decode($this->translator->translator("common_delete_selected"), ENT_QUOTES, "UTF-8"); ?></span></a></span>
        <?php endif; ?>
    </div>
</div>

<div id="dialog_container" title="<?php echo $this->translator->translator('common_dialog_msg',$this->translator->translator('menu_list_page_name')); ?>"></div>
<div id="dialog-confirm" title="<?php echo $this->translator->translator('common_confirmation',$this->translator->translator('common_delete')); ?>"></div>
<?php endif; ?>
</div>